{% extends 'myhome/index.html' %}
{% block title %}
<title>天天生鲜-全部订单</title>
{% endblock %}
{% block main %}

	<div class="main_con clearfix">
		<div class="left_menu_con clearfix">
			<h3>用户中心</h3>
			<ul>
				<li><a href="{% url 'myhome_order_manage' %}" >· 个人信息</a></li>
				<li><a href="{% url 'myhome_order_order' %}" class="active">· 全部订单</a></li>
				<li><a href="{% url 'myhome_order_addrIndex' %}">· 收货地址</a></li>
			</ul>
		</div>
		<div class="right_content clearfix">
				<h3 class="common_title2">全部订单</h3>
				{% for i in data %}
				{% if i.status == 0 %}
				<ul class="order_list_th w978 clearfix">
					<li class="col01">{{i.addtime}}</li>
					<li class="col02" style="width: 300px">订单号：{{i.dingId}}</li>
					<li class="col02 stress" style="">未支付</li>	
					<li width="15%" name="{{i.id}}"><a style="height: 20;font-size: 11px;line-height: 20px" href="#" class="oper_btn fukuan">点击付款</a></li>	

					<li width="15%" name="{{i.id}}"><a style="height: 20;font-size: 11px;line-height: 20px" href="#" class="oper_btn del">删除订单</a></li>
				</ul>
				{% endif %}
				{% for ii in i.orderinfo_set.all %}
				{% if i.status == 0  %}
				
				<table class="order_list_table w980">
					<tbody>
						<tr>
							<td width="55%">
								<ul class="order_goods_list clearfix">					
									<li class="col01"><img src="{{ii.pic_url}}"></li>
									<li class="col02 add" title="{{i.title}}">{{ii.title}}<em title="{{i.title}}">{{ii.price}}元</em></li>	
									<li class="col03">{{ii.num}}</li>
									<li class="col04">{{ii.price}}元</li>	
								</ul>
								<script type="text/javascript">
									  lens = $(".add").text().length
									  if (lens>10){
									    $(".add").text($(".add").text().slice(0,10)+"...")
									  }
								</script>
							</td>
							<td width="15%">{{i.priceSum}}元</td>
							<!-- <td width="15%">待付款</td> -->
							
							<!-- <td width="15%" name="{{i.id}}"><a href="#" class="oper_btn del">删除订单</a></td> -->
						</tr>
					</tbody>
				</table>
				{% endif %}
				{% endfor %}
				{% endfor %}
				{% for i in data %}
				{% if i.status != 2 and i.status != 0 %}
<ul class="order_list_th w978 clearfix">
					<li class="col01">{{i.addtime}}</li>
					<li class="col02" style="width: 300px">订单号：{{i.dingId}}</li>
					<li class="col02 stress">已支付</li>	
					{% if i.status == 3 or i.status == 1 %}
					<li class="col02 stress" style="width: 135px">未发货</li>	
					{% elif i.status == 4 %}
					<li class="col02 stress" style=" width:135px">已发货</li>	
					{% endif %}	
					<li width="15%" name="{{i.id}}"><a style="height: 20;font-size: 11px;line-height: 20px" href="#" class="oper_btn del">删除订单</a></li>	
				</ul>
				{% endif %}
				{% for ii in i.orderinfo_set.all %}
				{% if i.status != 2 and i.status != 0  %}
				
				<table class="order_list_table w980">
					<tbody>
						<tr>
							<td width="55%">
								<ul class="order_goods_list clearfix">					
									<li class="col01"><img src="{{ii.pic_url}}"></li>
									<li class="col02" title="{{ii.title}}" style="width: 250px;overflow: hidden;">{{ii.title}}<em></em></li>	
									<li class="col03">{{ii.num}}</li>
									<li class="col04"><span class="col04s">{{ii.price}}</span>元</li>	
								</ul>
							</td>
							<td width="15%" class="price"></td>
							<!-- <td width="15%">已付款</td> -->
							<td width="15%"><a href="#" class="oper_btn">查看物流</a></td>
							<!-- <td width="15%" name="{{i.id}}"><a href="#" class="oper_btn del">删除订单</a></td> -->
						</tr>
					</tbody>
				</table>
				{% endif %}
					{% endfor %}
					{% endfor %}
				<script type="text/javascript">
					$(".order_list_table").each(function(ind,el){
						a = $(el).find("li").eq(2).text()
						b = $(el).find(".col04s").text()
						$(el).find(".price").text((Number(a)*Number(b)).toFixed(2))
					})
				</script>
<!-- 				<div class="pagenation">
					<a href="#"><上一页</a>
					<a href="#" class="active">1</a>
					<a href="#">2</a>
					<a href="#">3</a>
					<a href="#">4</a>
					<a href="#">5</a>
					<a href="#">下一页></a>
				</div> -->
		</div>
	</div>
	<script type="text/javascript">
		// 删除
		$(".del").click(function(){
			tid = $(this).parent().attr("name")
			$.get('{% url "myhome_order_del" %}',{"id":tid},function(data){
				if(data == "ok"){
					alert("删除订单成功！")
					location.reload();
				}
			})
		})
		// 付款
		$(".fukuan").click(function(){
			tid = $(this).parent().attr("name")
			$.get('{% url "myhome_order_fu" %}',{"id":tid},function(data){
				if(data == "ok"){
					alert("付款成功！")
					location.reload();
				}
			})
		})
	</script>
{% endblock %}